import Home from '../pages/home/Home'
import Login from '../pages/login/Login'
import UserInfo from '../pages/userInfo/UserInfo'
import UserList from '../pages/userList/UserList'
import RoleList from '../pages/roleList/RoleList'
import Permission from '../pages/permission/Permission'
import Notfound from '../pages/404/404'
import Layout from '../layout/Layout'
import CreateQuestion from '../pages/createQuestion/CreateQuestion'
import Questions from '../pages/questions/Questions'
// import Paper from '../pages/paper/Paper'
import ClassList from '../pages/classList/classList'
import StudentList from '../pages/studentList/StudentList'
import GroupClass from '../pages/groupClass/GroupClass'
import ClassId from '../pages/classId/ClassId'


import ExamHistory from '../pages/examMangement/examHistory/ExamHistory'
import CreateExam from '../pages/examMangement/createExam/CreateExam'
import NoRight from '@/pages/403/403'
import Auth from './Auth'
import Papers from '../pages/paper/paperhome/Paper'
import CreatePaper from '../pages/paper/createpaper/CreatePaper'
import UserList2 from '../pages/userList/UserList2'

const routesConfig = [
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/',
    layout: true,
    permission: true,
    element: <Home />
  },
  {
    path: '/userManage/personal',
    layout: true,
    permission: true,
    element: <UserInfo />
  },
  {
    path: '/userManage/system',
    layout: true,
    permission: true,
    element: <RoleList />
  },
  {
    path: '/userManage/menuManage',
    layout: true,
    permission: true,
    element: <Permission />
  },
  {
    path: '/userManage/manage-page',
    layout: true,
    permission: true,
    element: <UserList />
  },
  {
    path:'/userManage/userOptions',
    layout: true,
    permission: true,
    element: <UserList2/>
  },
  {
    path: '/question/item-bank',
    layout: true,
    permission: true,
    element: <Questions />
  },
  {
    path: '/question/create-item',
    layout: true,
    permission: true,
    element: <CreateQuestion />
  },
  {
    layout: true,
    permission: true,
    path: '/paper/paper-bank',
    element: <Papers />
  },
  {
    layout: true,
    permission: true,
    path: '/manage-group/group-list',
    element: <ClassList />
  },
  {
    layout: true,
    permission: true,
    path: '/manage-group/group-students',
    element: <StudentList />
    
  },
  {
    layout: true,
    permission: true,
    path: '/manage-group/group-class',
    element: <GroupClass />
  },
  {
    layout: true,
    permission: true,
    path: '/group-detail/:id',
    element: <ClassId />,
  },
  {
    layout: true,
    permission: true,
    path: '/exam/record',
    element: <ExamHistory />
  },
  {
    layout: true,
    permission: true,
    path: '/exam/create',
    element: <CreateExam />
  },
  {
    layout: true,
    permission: true,
    path: '/student/list',
    element: <StudentList />
  },
  {
    layout: true,
    permission: true,
    path: '/paper/create-paper',
    element: <CreatePaper />
  },
  {
    path: '/403',
    element: <NoRight />

  },
  {
    path: '*',
    element: <Notfound />
  }
]

const fotmatRoutes = (routes: typeof routesConfig) => {
  return routes.map(item => {
    const routeItem = {
      ...item,
      element: item.permission ? <Auth>{item.element}</Auth> : item.element
    }
    if (item.layout) {
      routeItem.element = <Layout>{routeItem.element}</Layout>
    }
    return routeItem
  })
}


export default fotmatRoutes(routesConfig)